package main

import (
	"fmt"
	"log"
	"time"
)

func main() {

	lines := []string{
		"2024-07-27 17:01:27 +0800",
		"2024-07-26 17:01:27 +0800",
		"2024-07-26 10:01:27 +0800",
	}

	pattern := "2006-01-02 15:04:05 -0700"

	var timesP []time.Time

	for _, line := range lines {
		timeParse, err := time.ParseInLocation(pattern, line, time.Local)
		if err != nil {
			panic(fmt.Errorf("日期解析异常 timeStr:%s,error: %v", line, err))
		}

		log.Printf("==============> %s\n", timeParse)

		timesP = append(timesP, timeParse)
	}

	maxTimeP := time.Date(1990, 01, 01, 0, 0, 0, 0, time.Local)
	for _, timeP := range timesP {
		if timeP.After(maxTimeP) {
			maxTimeP = timeP
		}
	}

	log.Printf("========== lastest Time: %v\n", maxTimeP)
}
